package com.youmoula.mtsq

//import com.example.mtsq.ui.theme.MtsqTheme
import android.app.Application
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.viewModels
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.tooling.preview.Preview
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.compose.collectAsStateWithLifecycle


//import com.youmoula.mtsq.data.LocalAccountsDataProvider
import com.youmoula.mtsq.ui.theme.AppTheme
import java.lang.reflect.TypeVariable


class MainActivity : ComponentActivity() {
    //private val viewModel: ReplyHomeViewModel by viewModels()


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val viewModel = ViewModelProvider(
            this,
            ViewModelProvider.AndroidViewModelFactory.getInstance(application)
        ).get(ReplyHomeViewModel::class.java)
        setContent {
            AppTheme {
                val uiState by viewModel.uiState.collectAsStateWithLifecycle()
                ReplyEmailListContent(
                    modelInstance = viewModel,
                    replyHomeUIState = uiState,
                    emailLazyListState = LazyListState(),
                    closeDetailScreen = { viewModel.closeDetailScreen() },
                    navigateToDetail = { emailId -> viewModel.setSelectedEmail(emailId) }
                )
            }
        }
    }

}

//    @Preview(showBackground = true)
//    @Composable
//    fun GreetingPreview() {
//        AppTheme {
//            Greeting("Android")
//        }
//    }


//    @Preview(
//        uiMode = UI_MODE_NIGHT_YES,
//        name = "DefaultPreviewDark"
//    )
//    @Preview(
//        uiMode = UI_MODE_NIGHT_NO,
//        name = "DefaultPreviewLight"
//    )

//    @Composable
//    fun ReplyAppPreviewLight() {
//
//        ReplyApp(
//            modelInstance = ReplyHomeViewModel(Application()),
//            replyHomeUIState = ReplyHomeUIState()
//        )
//    }
